import { getToken } from './token';

// const request = (url: string, method: string, data_: object={}) => {
const request = ({url, method, data}:{url:string, method: string, data?:object}) => {
    const host = "http://127.0.0.1";
    const port = "8800";
    return fetch(`${host}:${port}${url}`, {
        method: method,
        headers: {
            'user-agent': 'Mozilla/4.0 MDN Example',
            "Content-Type": "application/json",
            'Authentication': getToken(),
        },
        body: method==='POST' || method === 'PATCH' ? JSON.stringify(data): null,
    })
}

export default request;